<template>
  Item 1: {{item1}}
  <br>
  Item list: {{itemList}}
</template>

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {
      item1: '',
      itemList: {
        name: '',
        password: ''
      }
    }
  },
  created() { // 页面加载时从后端fetch数据，赋值于变量并显示
    fetch("/api/v1/demo_item/1") // GET http://localhost:8080/api/v1/demo_item/1
      .then((response) => response.text())
      .then((data) => {
        this.item1 = data;
      })
    fetch("/api/v1/demo_item") // GET http://localhost:8080/api/v1/demo_item
      .then((response) => response.text())
      .then((data) => {
        this.itemList = data;
      })
  }
}
</script>
